Learning Spring 5.0 by Tejaswini Mandar Jog
Author:Tejaswini Mandar Jog [Jog, Tejaswini Mandar]
Language: eng
Format: azw3
Tags: COM051000 - COMPUTERS / Programming / General, COM051280 - COMPUTERS / Programming Languages / Java, COM051390 - COMPUTERS / Programming / Open Source
Publisher: Packt Publishing
Published: 2017-06-29T04:00:00+00:00
@Override public Book serachBook(longISBN) { // TODO Auto-generated method stub String SEARCH_BOOK = "select * from book where ISBN=?"; Book book_serached = null; try { book_serached =
jdbcTemplate.queryForObject(SEARCH_BOOK, new Object[] { ISBN }, new RowMapper<Book>(){ @Override public Book mapRow(ResultSet set, int rowNum) throws SQLException { Book book = new Book(); book.setBookName(set.getString("bookName")); book.setAuthor(set.getString("author")); book.setDescription(set.getString("description")); book.setISBN(set.getLong("ISBN")); book.setPrice(set.getInt("price")); book.setPublication(set.getString("publication")); return book; } }); return book_serached; } catch (EmptyResultDataAccessException ex) { return new Book(); } }
We have added an anonymous inner class, which is implementing RowMapper. RowMapper is used to bind column values that are fetched from the database table to the object of Book returned by the queryForObject() method. The code is searching for the book, and then the column values from ResultSet are bounded to the Book object. We returned an object with default values just for our business logic.
Add the BookService interface as a service layer in the com.packt.ch05.service package with the following method signatures:
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Deep Learning with Python by François Chollet(12579)
Hello! Python by Anthony Briggs(9918)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9797)
The Mikado Method by Ola Ellnestam Daniel Brolund(9780)
Dependency Injection in .NET by Mark Seemann(9341)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8303)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7764)
Grails in Action by Glen Smith Peter Ledbrook(7699)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7558)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(7101)
Microservices with Go by Alexander Shuiskov(6870)
Practical Design Patterns for Java Developers by Miroslav Wengner(6783)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6726)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6420)
Angular Projects - Third Edition by Aristeidis Bampakos(6141)
The Art of Crafting User Stories by The Art of Crafting User Stories(5661)
NetSuite for Consultants - Second Edition by Peter Ries(5596)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5405)
Kotlin in Action by Dmitry Jemerov(5067)
